﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="xbrlesita_yldandmed", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(XbrlesitaYldandmed))]
    public class XbrlesitaYldandmedSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IXbrlesitaYldandmed clazz;
        
        public XbrlesitaYldandmedSerializer(IXbrlesitaYldandmed clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("ariregistri_kood");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.AriregistriKood))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("majaasta_algus");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.MajaastaAlgus))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("majaasta_lopp");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.MajaastaLopp))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("standard");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Standard))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("standard_tekstina");
            if (clazz.StandardTekstina!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.StandardTekstina))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : StandardTekstina");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("konsolideeritud");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "boolean");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdBoolean(((bool)(clazz.Konsolideeritud))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("erandid");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Erandid))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("erandid_tekstina");
            if (clazz.ErandidTekstina!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.ErandidTekstina))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : ErandidTekstina");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("tapsusaste");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Tapsusaste))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("tapsusaste_tekstina");
            if (clazz.TapsusasteTekstina!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.TapsusasteTekstina))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : TapsusasteTekstina");
            }
            Writer.WriteEndElement();
            if (clazz.AruandeLiik!=null) {
                Writer.WriteStartElement("aruande_liik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AruandeLiik))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.XbrlFileId!=null) {
                Writer.WriteStartElement("xbrl_file_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.XbrlFileId))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.DdocFileId!=null) {
                Writer.WriteStartElement("ddoc_file_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.DdocFileId))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.XbrlAruandeId!=null) {
                Writer.WriteStartElement("xbrl_aruande_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.XbrlAruandeId))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="ariregistri_kood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesita_yldandmed>ariregistri_kood");
                }
                clazz.AriregistriKood = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("ariregistri_kood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_yldandmed>ariregistri_kood", Reader.LocalName);
            }
            if (Reader.LocalName=="majaasta_algus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesita_yldandmed>majaasta_algus");
                }
                clazz.MajaastaAlgus = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("majaasta_algus")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_yldandmed>majaasta_algus", Reader.LocalName);
            }
            if (Reader.LocalName=="majaasta_lopp") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesita_yldandmed>majaasta_lopp");
                }
                clazz.MajaastaLopp = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("majaasta_lopp")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_yldandmed>majaasta_lopp", Reader.LocalName);
            }
            if (Reader.LocalName=="standard") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesita_yldandmed>standard");
                }
                clazz.Standard = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("standard")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_yldandmed>standard", Reader.LocalName);
            }
            if (Reader.LocalName=="standard_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesita_yldandmed>standard_tekstina");
                }
                clazz.StandardTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("standard_tekstina")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_yldandmed>standard_tekstina", Reader.LocalName);
            }
            if (Reader.LocalName=="konsolideeritud") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesita_yldandmed>konsolideeritud");
                }
                clazz.Konsolideeritud = new global::Xtee.Core.Schema.XsdBoolean(Reader.ReadElementString("konsolideeritud")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_yldandmed>konsolideeritud", Reader.LocalName);
            }
            if (Reader.LocalName=="erandid") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesita_yldandmed>erandid");
                }
                clazz.Erandid = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("erandid")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_yldandmed>erandid", Reader.LocalName);
            }
            if (Reader.LocalName=="erandid_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesita_yldandmed>erandid_tekstina");
                }
                clazz.ErandidTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("erandid_tekstina")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_yldandmed>erandid_tekstina", Reader.LocalName);
            }
            if (Reader.LocalName=="tapsusaste") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesita_yldandmed>tapsusaste");
                }
                clazz.Tapsusaste = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("tapsusaste")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_yldandmed>tapsusaste", Reader.LocalName);
            }
            if (Reader.LocalName=="tapsusaste_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesita_yldandmed>tapsusaste_tekstina");
                }
                clazz.TapsusasteTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("tapsusaste_tekstina")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_yldandmed>tapsusaste_tekstina", Reader.LocalName);
            }
            if (Reader.LocalName=="aruande_liik") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AruandeLiik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aruande_liik")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="xbrl_file_id") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.XbrlFileId = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("xbrl_file_id")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="ddoc_file_id") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.DdocFileId = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("ddoc_file_id")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="xbrl_aruande_id") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.XbrlAruandeId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("xbrl_aruande_id")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
        }
    }
}
